<template>
	<w-collapse v-model="collapseVisible" disabled :showArrow="false" title="基础信息">
		<el-form ref="form" :model="programDetails" :rules="rules" size="mini" label-width="130px" inline>
			<el-form-item label="生产计划编号：">
				<w-input
					v-model="programDetails.code"
					disabled
					class="form-item-input"
				></w-input>
			</el-form-item>
			<el-form-item prop="factoryId" label="工厂：">
        <w-select
					v-model="programDetails.factoryId"
					:optionlist="FactoryList"
					:disabled="disabled"
					class="form-item-input"
					@change="changeFactory"
				>
				</w-select>
			</el-form-item>
			<el-form-item prop="productionPlanDate" label="生产计划日期：">
				<el-date-picker
					ref="productionPlanDate"
					v-model="programDetails.productionPlanDate"
					type="datetime"
					value-format="yyyy-MM-dd HH:mm:00"
					format="yyyy-MM-dd HH:mm"
					placeholder="选择日期"
					:clearable="false"
					:disabled="disabled"
					class="form-item-input"
				></el-date-picker>
			</el-form-item>
			<el-form-item prop="receivedDate" label="交付日期：">
				<el-date-picker
					ref="receivedDate"
					v-model="programDetails.receivedDate"
					type="datetime"
					value-format="yyyy-MM-dd HH:mm:00"
					format="yyyy-MM-dd HH:mm"
					placeholder="选择日期"
					:clearable="false"
					:disabled="disabled"
					class="form-item-input"
				></el-date-picker>
			</el-form-item>
			<el-form-item label="制单人：">
				<w-input
					v-model="programDetails.createUserName"
					disabled
					class="form-item-input"
				></w-input>
			</el-form-item>
			<el-form-item label="制单日期：">
				<el-date-picker
					ref="createDate"
					v-model="programDetails.createDate"
					type="datetime"
					value-format="yyyy-MM-dd HH:mm:00"
					format="yyyy-MM-dd HH:mm"
					placeholder="选择日期"
					:clearable="false"
					disabled
					class="form-item-input"
				></el-date-picker>
			</el-form-item>
			<el-form-item label="审核人：">
				<w-input
					v-model="programDetails.auditUser"
					disabled
					class="form-item-input"
				></w-input>
			</el-form-item>
			<el-form-item label="审核日期：">
				<w-input
					v-model="programDetails.auditDate"
					disabled
					class="form-item-input"
				></w-input>
			</el-form-item>
			<el-form-item prop="importType" label="数据来源：">
				<el-select v-model="programDetails.importType" prop="importType"
				placeholder="请选择" clearable size='mini' disabled class="form-item-input">
					<el-option
						v-for="item in importTypeList"
						:key="item.id"
						:label="item.label"
						:value="item.id"
					>
					</el-option>
				</el-select>
			</el-form-item>
			<el-form-item prop="remark" label="备注：">
				<w-input
					v-model="programDetails.remark"
					:maxlength="$fxCommon.getFxInputMaxLength('remark')"
					:regType="$fxCommon.getFxInputReg('remark')"
					:disabled="disabled"
					class="form-item-input-memo"
				></w-input>
			</el-form-item>
		</el-form>
	</w-collapse>
</template>
<script>
export default {
	name: 'basicInfo',
	props: {
		visibleFlag: Boolean,
		programDetails: {
			type: Object,
			default: () => {
				return {}
			}
		},
		FactoryList: {
			type: Array,
			default: () => {
				return []
			}
		},
		disabled: Boolean
	},
	data () {
		return {
			collapseVisible: true,
			rules: {
				code: [{ required: true, message: '该字段不能为空', trigger: 'change' }],
				factoryId: [{ required: true, message: '该字段不能为空', trigger: 'change' }],
				productionPlanDate: [{ required: true, message: '该字段不能为空', trigger: 'change' }],
				receivedDate: [{ required: true, message: '该字段不能为空', trigger: 'change' }]
			},
			importTypeList: [{
				id: '0',
				label: '手工新建'
			}, {
				id: '1',
				label: 'SCM导入'
			}]
		}
	},
	watch: {
		visibleFlag: {
			immediate: true,
			handler (val) {
				if (val) {
					this.refresh()
				}
			}
		}
	},
	methods: {
		refresh () {
			this.$nextTick(() => {
				this.$refs.form.clearValidate()
			})
		},
		validate () {
			return this.$refs.form.validate()
		},
		changeFactory (val) {
			this.$emit('changeFactory', val)
		}
	}
}
</script>
<style lang="stylus" scoped>
@import '~$assets/stylus/varsty.styl'
.form-item-input {
	width: 175px
}
.form-item-input-memo {
	width: 490px
}
.form-switch-input {
	width: 275px
}
.form-input-add-btn {
	position: absolute
	top: 3px
	right: -25px
}
.form-item__plan-message {
	font-size: 10px;
    position: absolute;
    height: 16px;
    line-height: 16px;
	display: flex;
    width: 175px;
    justify-content: space-between;
}
</style>
